"principal line of a railway," 1841, from main (adj.) + line (n.). Meaning "affluent area of residence" is by 1917, originally (with capitals) that west of Philadelphia, from the "main line" of the Pennsylvania Railroad which added local stops to a string of backwater towns west of the city late 19c. that helped turn them into fashionable suburbs.
The Main Line, Philadelphia's most famous suburban district, was deliberately conceived in the 1870's and 1880's by the [Pennsylvania] Railroad, which built high-toned housing developments, ran hotels, more or less forced its executives to plunk their estates out there, and created a whole series of somewhat spurious Welsh towns along the railroad tracks. ... Now everybody assumes these all date from 1682, like the Robertses; but as Chestnut Hill people like to say, "nobody but Welsh peasants lived on the Main Line till the Railroad built it up." [Nathaniel Burt, "The Perennial Philadelphians," 1963]
The original station stops were, in order out from the city, Overbrook, Merion, Narberth, Wynnewood, Ardmore, Haverford, Bryn Mawr, Paoli. The train line for commuters along it is the Paoli Local.